from rest_framework.generics import ListAPIView
from rest_framework.viewsets import ModelViewSet
from django.contrib.auth.models import Permission

from meiduo_admin.permission.permission_serializers import PermissionSerializer, PermissionContentTypeSerializer
from meiduo_admin.user.my_pagination import MyNumberPagination
from django.contrib.contenttypes.models import ContentType


# 获取全部权限
class PermissionViewSet(ModelViewSet):
    pagination_class = MyNumberPagination
    serializer_class = PermissionSerializer
    queryset = Permission.objects.all()


class PermissionContentTypeViewSet(ListAPIView):
    pagination_class = None
    queryset = ContentType.objects.all()
    serializer_class = PermissionContentTypeSerializer
